package com.sky.alogrithm.chapter01_data_structure;

public class Stack<T>{

    private Node first;
    private int N;


    private class Node{
        T t;
        Node next;
    }

    public boolean isEmpty(){
        return first == null;
    }

    public int size(){
        return N;
    }

    public void push(T t){
        Node oldFirst = first;
        first = new Node();
        first.t = t;
        first.next = oldFirst;
        N++;
    }

    public T pop(){
        T t = first.t;
        first = first.next;
        N--;
        return t;
    }
}
